<!-- 卖出记录 -->
<template>
  <div class="sell-record">
    <van-cell title="日期筛选" :value="date" @click="dateshow">

    </van-cell>
    <van-cell style="text-align:center">
      <div style="width:50%;float:left;    text-align: center;">
        <van-button type="primary" @click="searchData" style="background-color:rgb(77, 173, 249);border:0px">查询</van-button>
      </div>
      <div style="width:50%;float:left;    text-align: center;">
        <van-button type="primary" style="margin-left:20px;background-color:rgb(77, 173, 249);border:0px" @click="clearDate">清除日期</van-button>
      </div>


    </van-cell>

    <div class="item" @click="goEdit(item)" v-for="item in items" :key="item.id">
      <div>池塘名称：{{ item.areaname }}</div>
      <div>卖出时间：{{ item.time }}</div>
      <div>
        <div>备注：</div>
        <div>
          {{ item.descs }}
        </div>
      </div>
    </div>
    <van-pagination v-model="page" :total-items="count" @change="getData" :items-per-page="rows" />
  </div>
</template>

<script>
import Bus from '../../../utils/bus.js'
import { Pagination } from 'vant';
import { patrolAreaList } from "../../../api/patrol_area";
export default {
  name: "sell-record",
  components: {
    Pagination,
  },
  props: {
    list: {
      type: Array,
    },
  },
  data() {
    return {
      items: [],
      page: 1,
      rows: 4,
      pages: 0,
      count: 0,
      date: '',
      stime: '',
      etime: ''
    };
  },
  methods: {
    dateshow() {

      Bus.$emit('dateshow', "1")

    },
    goEdit(uitem) {
      this.$router.push({ path: "/edit-record", query: { id: uitem.id, type: 3 } });
    },
    async getData() {

      let res = await patrolAreaList({
        userid: localStorage.getItem("userid"), type: 3, page: this.page, rows: this.rows,
        stime: this.stime, etime: this.etime
      });

      console.log("res", res);
      if (res.status == 200) {
        var list = res.data;
        this.items = list;
        this.count = res.count;

      }
    },
    setDate(stime, etime) {
      this.stime = stime;
      this.etime = etime;
      console.log("设置完成时间", stime, etime);
      this.date = stime + "至" + etime;
    },
    clearDate() {
      this.stime = "";
      this.etime = "";
      this.date = "";
    },
    searchData() {
      this.page = 1;
      this.getData();
    }
  },
  computed: {},
  watch: {},
  created() {
    this.getData();
  },
  mounted() { },
};
</script>

<style lang="scss" scoped>
.sell-record {
  width: 100%;
  padding: 20px 0 0 0;
  padding-bottom: 120px;

  .item {
    width: 100%;
    background-color: #fff;
    min-height: 240px;
    padding: 30px 20px;
    font-size: 24px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;

    > :last-child {
      display: flex;

      > :last-child {
        flex: 1;
      }
    }
  }
}
</style>